home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / PJPARK.ASM < prev    next >
Assembly Source File  |  1985-05-03  |  5KB  |  296 lines

  1. title    'Park Disk Routine for Hard Disks 5-3-85'
  2.  
  3. ;
  4. ;    Hard Disk Parking Routine for MSDOS
  5. ;    Version for Seagate 20-60 meg drives, though should work for
  6. ;    any size hard disks
  7. ;
  8. ;    Currently setup for DOS and MASM
  9. ;
  10. ;    Also provides limited diagnostics (ie Drive Parameters)
  11. ;    and parks multiple drives
  12. ;
  13. ;    Author:        M. Steven Baker
  14. ;    Revision date    January 31, 1985
  15. ;    Last revision    May 3, 1985
  16. ;
  17. ;    If using MASM use exe2bin to convert to a .COM file
  18. ;    you can then load PARK.com with debug and change CX=260
  19. ;    and W (write) out the file shrinking its size 
  20. ;    This chops off the 200h bytes of stack space from the COM file
  21. ;
  22. ;    E Q U A T E S
  23. ;
  24. cr    equ    0dh
  25. lf    equ    0ah
  26. ESC    equ    1bh
  27. ;
  28. false    equ    0
  29. true    equ    not false    
  30. ;
  31. CPM86    equ    false
  32. MSDOS    equ    not CPM86
  33.  
  34. MASM    equ    true
  35.  
  36.     if    MASM        ;use some Macros
  37. jmps    macro    dummy
  38.     jmp    short     dummy
  39.     endm
  40. ;
  41. rs    macro    count
  42.     db    count dup(?)
  43.     endm
  44.  
  45. cseg    macro
  46.     CODE    segment
  47.     assume    cs:CODE,ds:CODE,es:CODE,ss:CODE
  48.     endm
  49.  
  50.     ENDIF    ;MASM
  51.  
  52.  
  53. ;
  54.     cseg
  55.  
  56.     ORG    0100h
  57. ;
  58. start:    jmps    start1
  59. dosflg:    dw    MSDOS        ;0=CPM86 FF=dos
  60. ;
  61. start1:    mov    ax,cs
  62.     mov    ds,ax
  63.     mov    es,ax
  64.     mov    ss,ax
  65.     mov    sp,offset stktop
  66.     cld
  67. ;
  68.     call    ilprt
  69.     db    cr,lf,'Park version 2.01  5-3-85 (msb)',cr,lf,0
  70. ;
  71. parkit:    mov    dx,80h
  72.     push    dx
  73.     call    getparms
  74.     jnc    parm_ok
  75. parker:    jmp    parm_err
  76. ;
  77. parm_ok: mov    ax,dx
  78.     pop    dx
  79. ;
  80.     push    ax
  81.     call    ilprt    
  82.     db    'DRIVE PARMETERs: TotDrvs=',0
  83.     pop    ax
  84.     push    ax
  85.     add    al,'0'        ;AL = number of drives
  86.     call    conout
  87.     pop    ax
  88.     call    crlf
  89. ;
  90.     xor    cx,cx        ;zero CX as loop counter
  91.     mov    cl,al
  92.     or    cx,cx        ; are there any drives
  93.     jz    nodrives
  94. ;
  95. parklp:    push    cx        ;save number of drives
  96.     push    dx        ;save drive number
  97.     mov    ax,1100h    ;recalibrate hard disk
  98.     int    13h
  99.     jnc    recal_ok
  100.     jmp    recal_err
  101. ;
  102. recal_ok:
  103.     call    getparms
  104.     jnc    ok_2
  105.     jmp    parm_err
  106. ;
  107.  
  108. ok_2:    mov    ax,dx
  109.     pop    dx        ;restore drive number
  110.     push    dx
  111.     call    sayparms
  112.     MOV    AX,0C00H    ;seek command
  113.     INT    13H
  114.     jc    seek_err
  115. ;
  116.     pop    dx
  117.     inc    dx        ; go to next drive
  118.     pop    cx        ;get back loop counter
  119.     loop    parklp
  120.  
  121.     call    ilprt
  122.     db    CR,LF,'Head(s) parked !!',CR,LF,0
  123.  
  124.     jmp    exit        ;and terminate
  125. ;
  126. nodrives:
  127.     call    ilprt
  128.     db    cr,lf,'NO HARD DISK drives installed',cr,lf,0
  129.     jmp    exit
  130. ;
  131. seek_err:
  132.     call    ilprt
  133.     db    cr,lf,'Seek error on drive ',0
  134.     call    saydrive
  135.     jmp    abort
  136.  
  137. recal_err:
  138.     call    ilprt
  139.     db    cr,lf,'Recalibrate error on drive ',0
  140.     call    saydrive
  141.     jmp    abort
  142.  
  143. parm_err:
  144.     call    ilprt
  145.     db    cr,lf,'Disk Parameter call returned error on drive ',0
  146.     call    saydrive
  147.     jmp    abort
  148.  
  149. saydrive:
  150.     push    ax
  151.     mov    al,dl        ;get hard disk drive # to AL
  152.     and    al,7fh        ;strip 8th bit
  153.     add    al,'0'
  154.     call    conout
  155.     pop    ax
  156.     ret
  157.  
  158. getparms:
  159.     mov    ax,0800h    ;get current drive parameters
  160.     int    13h
  161.     ret
  162.  
  163. ;    S A Y P A R M S
  164. ;    entry:    DL = drive number
  165. ;        AL = number of consecutive drives
  166. ;        AH = maximum useable head number        
  167. ;        CH = maximum useable value for cylinder
  168. ;        CL = maximum useable value for sector number
  169. ;            and cylinder number high bits
  170. ;    exit:    all registers preserved
  171.  
  172. sayparms:
  173.     push    ax
  174.     push    bx
  175.     push    cx
  176.     push    dx
  177. ;
  178.     push    ax
  179.     call    ilprt    
  180.     db    'DRIVE PARMs:   Drv=',0
  181.     mov    al,dl        ;Drive #
  182.     and    al,7fh        ;strip off lower bits
  183.     add    al,'0'
  184.     call    conout        ;say drive
  185. ;
  186.     call    ilprt
  187.     db    '  Heads=',0
  188.     pop    ax        ;restore heads and tot drives
  189.     xchg    ah,al
  190.     call    hexout
  191. ;
  192.     call    ilprt
  193.     db    '  Cyls=',0
  194.     push    cx        ;save cylinders and sectors
  195.     mov    ax,cx
  196.     and    ax,0c0h        ;strip off high bits of CL
  197. ;
  198.     push    cx
  199.     mov    cx,6
  200. shloop:    shr    ax,1
  201.     loop    shloop
  202.     pop    cx
  203. ;
  204.     call    hexout
  205.     pop    cx        ;restore CX = sectors & cylinders
  206.     mov    al,ch        ;now lower 8 bits of cylinders
  207.     call    hexout
  208.     mov    al,'h'
  209.     call    conout
  210. ;
  211.     call    ilprt
  212.     db    '  Sectors= ',0
  213.     mov    al,cl
  214.     and    al,3fh        ;strip off lower 6 bits
  215.     call    hexout
  216.     mov    al,'h'
  217.     call    conout
  218. ;
  219.     call    crlf
  220. ;
  221.     pop    dx
  222.     pop    cx
  223.     pop    bx
  224.     pop    ax
  225.     ret
  226. ;
  227. conout:    push    ax
  228.     push    bx
  229.     push    dx
  230.     mov    dl,al
  231.     mov    ah,6
  232.     int    21h        ;change this to a CALL BDOS for CP/M
  233.     pop    dx
  234.     pop    bx
  235.     pop    ax
  236.     ret
  237. ;
  238. ilprt:
  239.     pop    si
  240. ilprt1:    lodsb
  241.     or    al,al
  242.     jz    ilprtr
  243.     call    conout
  244.     jmps    ilprt1
  245. ilprtr:    push    si
  246.     ret
  247. ;
  248. hexout:    push    ax
  249.     shr    al,1
  250.     shr    al,1
  251.     shr    al,1
  252.     shr    al,1
  253.     call    pnib
  254.     pop    ax
  255.     push    ax
  256.     call    pnib
  257.     pop    ax
  258.     ret
  259. ;
  260. pnib:    and    al,0fh
  261.     add    al,'0'
  262.     cmp    al,'9'
  263.     jbe    pnib2
  264.     add    al,7
  265. pnib2:
  266.     call    conout
  267.     ret
  268.  
  269. crlf:    push    ax
  270.     mov    al,CR
  271.     call    conout
  272.     mov    al,LF
  273.     call    conout
  274.     pop    ax
  275.     ret
  276. abort:
  277.     call    ilprt
  278.     db    '  .. Aborting',cr,lf,0
  279. exit:    mov    ax,0
  280.     int    21h        ;change to a call BDOS for CP/M
  281. exit1:    jmps    exit1
  282. ;
  283.     db    0
  284.  
  285.     even
  286.  
  287. ;temp    equ    $ and 0fffeh        ;make on even boundary for CP/M-86
  288. ;
  289. ;    org    temp
  290.     RS    200h
  291. stktop    dw    0
  292.     dw    0
  293. ;
  294.     CODE    ends
  295.     end    start        ;put starting label routine at 100h
  296.